n,e=map(int,input().split())
tmp=[list(map(int,input().split())) for i in range(n)]
print(tmp)
offsets=[0]*e
for x,offsetY in tmp:
    offsets[x]=offsetY
def getResult():
    if e==0:
        return 0
    height=[0]*e
    asn=height[0]=offsets[0]
    for i in range(1,e):
        height[i]=height[i-1]+offsets[i]
        asn=asn+(abs(height[i])*1)
    return asn
print(getResult())